package UserSum;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class RedTest extends Reducer<User, NullWritable, User, NullWritable> {
    User k = new User();
    int sum_num = 0;

    @Override
    protected void reduce(User key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) {
            sum_num += key.getNum();
        }
        k.set(key.getId(), key.getHour(), sum_num, key.getDate());
        context.write(k, NullWritable.get());
        sum_num = 0;
    }
}
